#ifndef __TOYM__NET__EVENT_LOOP_THREAD_POOL_H__
#define __TOYM__NET__EVENT_LOOP_THREAD_POOL_H__

#include <vector>
#include <memory>
#include "Base/noncopyable.h"
#include "net/Callables.h"

namespace toym
{
namespace net
{

class EventLoop ;
class EventLoopThread;

class EventLoopThreadPool: noncopyable{
public:
    EventLoopThreadPool(EventLoop* baseLoop);
    ~EventLoopThreadPool();

    // 设置线程数量
    void setThreadNum(int nThread) {
        m_nThread = nThread;
    }

    // 启动线程
    void start(ThreadInitCallback_t cb = ThreadInitCallback_t());

    // 获取下一个线程
    EventLoop* nextLoop();

private:
    EventLoop* m_baseLoop;
    bool m_started;
    int m_nThread;
    int m_next;
    std::vector<std::unique_ptr<EventLoopThread>> m_threads;
    // std::unique_ptr<std::vector<EventLoopThread>> m_threads;
    std::vector<EventLoop*> m_loops;
};

} // namespace net

} // namespace toym


#endif